/*  File Name	: MsgBlockPool.cpp
 *  Author		: Pang Jiacai
 *	 E-mail		: 823960168@qq.com
 *  Created on	: 2012-7-2
 *  Description:
 */

#include "MsgBlockPool.h"

MsgBlockPool::MsgBlockPool(int block_size,std::string name)
{
	block_size = block_size > 0 ? block_size : 1024;
	block_pool_ = new BlockPool(10240,512,block_size);
	block_pool_ ->set_malloc_mode(MODE_USE_NEW_SIZE);
	this->set_pool_name(name);
}

MsgBlockPool::~MsgBlockPool()
{
	if(NULL!=this->block_pool_)
	{
		delete this->block_pool_;
		this->block_pool_ = NULL;
	}
}

void MsgBlockPool::set_pool_name(std::string name)
{
	this->block_pool_->set_pool_name(name);
}

int MsgBlockPool::block_size(void)
{
	return this->block_size_;
}

int MsgBlockPool::push( MessageBlock *mb)
{
	return this->block_pool_->push(mb);
}

int MsgBlockPool::pop(MessageBlock *&mb)
{
	return this->block_pool_->pop(mb);
}
